package com.fitz.demo.consumer.controller;

import com.fitz.annotation.RpcReference;
import com.fitz.demo.service.HelloService;
import com.fitz.enums.ClusterStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/index")
@Slf4j
public class DemoController {

    @RpcReference(clusterStrategy = ClusterStrategy.FAILOVER)
    private HelloService helloService;

    @GetMapping("/hello")
    public Object hello(@RequestParam("message")String message){
        String result = helloService.hello(message);
        log.info("receiveResult:{}",result);
        return result;
    }
}
